import { getMenus, getRightList } from '@/api/rights.js'

const state = {
  // 左侧菜单
  menusList: [],
  // 所有权限列表
  rightsList: []
}
const mutations = {
  initMenusList(state, payload) {
    state.menusList = payload
  },
  initRightsList(state, payload) {
    state.rightsList = payload
  }
}
const actions = {
  // 左侧菜单
  async getMenusList(context) {
    const list = await getMenus()
    // console.log(list)
    context.commit('initMenusList', list)
  },
  // 所有权限列表
  async getRightsList(context) {
    const res = await getRightList('list')
    // console.log(res)
    context.commit('initRightsList', res)
  }
}
const getters = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
